let g:Lf_WildIgnore = {
        \ 'dir': ['.svn','.git','.hg'],
        \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]']
        \}
let g:Lf_WindowPosition = 'popup'
if executable("gtags")
  let g:Lf_GtagsAutoGenerate = 1
endif
let g:Lf_PopupWidth = 0.99
let g:Lf_Gtagslabel = 'native-pygments'
let g:Lf_ShortcutB = ''
nnoremap <space>l :<c-u>LeaderfLine<cr>

" search word under cursor, the pattern is treated as regex, and enter normal mode directly
"noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR>
noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -F -e %s -g !tags", expand("<cword>"))<CR><CR>

" search word under cursor, the pattern is treated as regex,
" append the result to previous search results.
"noremap <C-G> :<C-U><C-R>=printf("Leaderf! rg --append -e %s ", expand("<cword>"))<CR><CR>

" search word under cursor literally only in current buffer
noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg -F --current-buffer -e %s ", expand("<cword>"))<CR><CR>

" search word under cursor literally in all listed buffers
"noremap <C-D> :<C-U><C-R>=printf("Leaderf! rg -F --all-buffers -e %s ", expand("<cword>"))<CR><CR>

" search visually selected text literally, don't quit LeaderF after accepting an entry
" --stayOpen
xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s -g !tags", leaderf#Rg#visual())<CR><CR>
xnoremap gb :<C-U><C-R>=printf("Leaderf! rg -F --current-buffer -e %s -g !tags", leaderf#Rg#visual())<CR><CR>

" recall last search. If the result window is closed, reopen it.
noremap go :<C-U>Leaderf! rg --recall<CR>


" search word under cursor in *.h and *.cpp files.
"noremap <Leader>a :<C-U><C-R>=printf("Leaderf! rg -e %s -g *.h -g *.cpp", expand("<cword>"))<CR>
" the same as above
"noremap <Leader>a :<C-U><C-R>=printf("Leaderf! rg -e %s -g *.{h,cpp}", expand("<cword>"))<CR>

" search word under cursor in cpp and java files.
"noremap <Leader>b :<C-U><C-R>=printf("Leaderf! rg -e %s -t cpp -t java", expand("<cword>"))<CR>

" search word under cursor in cpp files, exclude the *.hpp files
"noremap <Leader>c :<C-U><C-R>=printf("Leaderf! rg -e %s -t cpp -g !*.hpp", expand("<cword>"))<CR>
